#include <iostream>
#include <cstdio>
#define MAXN 2333
using namespace std;

int n, x[MAXN], y[MAXN], f[MAXN], ans, k;
bool g[MAXN][MAXN];

inline int read() {
	int k = 0;
	char c = getchar();
	for(;!isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar())
		k = k * 10 + c - '0';
	return k;
}

int dp(int i) {
	if(!f[i]) {
		f[i] = 1;
		for(int j= 1; j <= n; j++) {
			if(g[i][j]) {
				f[i] = max(f[i], dp(j) + 1);
			}
		}
	}
	return f[i];
}

void print(int k) {
	printf("%d ",k);
	for(int i = 1; i <= n; i++) {
		if(g[k][i] && f[k] == f[i] + 1) {
			print(i);
			break;
		}
	}
}

int main(){
#ifndef LOCAL
	freopen("qiantao.in", "r", stdin);
	freopen("qiantao.out", "w", stdout);
#endif
	n = read();
	
	for(int i = 1;i <= n; i++) {
		x[i] = read();
		y[i] = read();
		if(y[i] < x[i]) swap(y[i], x[i]);
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(x[j] > x[i] && y[j] > y[i]) {
				g[i][j] = 1;
			}
		}
	}
	
	for(int i = 1; i <= n; i++) {
		if(dp(i) > ans) {
			ans = f[i];
			k = i;
		}
	}
	
	printf("%d\n",ans);
	
	print(k);
	
	return 0;
}
